#ifndef NODE_H
#define NODE_H

#include <QList>
#include <QHash>
#include <QString>

class Node;
#include "parser_yacc.h"

class Namespace;
class Type;

class Node
{
public:
    Node* parentNode() const { return m_parentNode; }
    Node* firstChild() const { if ( m_children.isEmpty() ) return 0; return m_children.first(); }
    Node* lastChild() const { if ( m_children.isEmpty() ) return 0; return m_children.last(); }
    Node* previousSibling() const { return m_previousSibling; }
    Node* nextSibling() const { return m_nextSibling; }

    void insertBefore( Node* child, Node* before = 0 );
    void appendChild( Node* child );
    void removeChild( Node* child );

    int childCount() const { return m_children.count(); }

    const YYLTYPE& location() const { return m_loc; }
    void includeLocation(const YYLTYPE& loc);

    Namespace* nspace() const;

    QHash<QString,QString>& data() { return m_data; }

    virtual void resolveAll();
    virtual Type type();

protected:
    Node();
    Node( const YYLTYPE& loc );
    virtual ~Node() { }

private:
    Node* m_parentNode;
    Node* m_previousSibling;
    Node* m_nextSibling;
    QList<Node*> m_children;
    YYLTYPE m_loc;
    QHash<QString,QString> m_data;
};

#endif // NODE_H
